package tt.dz.appserver.service.business.imp;

import java.util.List;

import javax.annotation.Resource;

import org.apache.avro.AvroRemoteException;

import com.alibaba.fastjson.JSONObject;

import tt.dz.appserver.dao.ext.CommentDao;
import tt.dz.appserver.entity.model.pub.Comment;
import tt.dz.appserver.service.business.CommentService;
import tt.dz.appserver.util.enums.Response;

/**
 * 评论管理实现类
 * @author USER001
 *
 */

public class CommentServiceImpl implements CommentService {

	@Resource
	private CommentDao commentDao;
	
	@Override
	public JSONObject pubcommentdel(String commentid) throws AvroRemoteException {
		// TODO Auto-generated method stub
		Comment comment = new Comment();
		JSONObject resultJsonObject = new JSONObject();
		Integer validflag = 0;		
		
		comment.setComment_id(commentid);
		comment.setValid_flag(validflag);
		
		commentDao.update(comment);
		
		resultJsonObject.put("commentid", commentid);
		resultJsonObject.put("validflag", validflag);
		resultJsonObject.put("code", Response.SUCCESS.getCode());
		resultJsonObject.put("msg", Response.SUCCESS.getMsg());
		
		return resultJsonObject;
	}

	@Override
	public List<Comment> pubcommentselect(Integer associatetype, String associateid) throws AvroRemoteException {
		// TODO Auto-generated method stub
		
		return commentDao.findPubCommentValid(associatetype, associateid);
		
	}

}
